package com.ada;

import com.esotericsoftware.yamlbeans.YamlException;
import com.esotericsoftware.yamlbeans.YamlReader;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.ho.yaml.Yaml;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Map;

/**
 * Unit test for simple App.
 */
public class AppTest2
        extends TestCase {
    /**
     * Create the test case
     *
     * @param testName name of the test case
     */
    public AppTest2(String testName) {
        super(testName);
    }

    /**
     * @return the suite of tests being tested
     */
    public static Test suite() {
        return new TestSuite(AppTest2.class);
    }

    /**
     * Rigourous Test :-)
     */
    public void testApp() {
        assertTrue(true);
        int length=0;

        try {
            Object object = Yaml.load(new File("E:\\mvnspace\\android-arsenal.com\\projects\\free.yml"));
            System.out.println(object.getClass());
            Map map = (Map) object;
            ArrayList list = (ArrayList) map.get("categories");
            for (int i = 0; i < list.size(); i++) {
                Object o = list.get(i);
                Map mapx = (Map) o;
                System.out.println(mapx.get("name"));
                ArrayList items = (ArrayList) mapx.get("projects");
                for (int j = 0; j < items.size(); j++) {
                    Object o1 = items.get(j);
                    Map xxx = (Map) o1;
                    System.out.println(xxx.get("name"));
                    System.out.println(xxx.get("url"));
                    length++;
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        //E:\mvnspace\android-arsenal.com\projects\free.yml


    }
}
